<template>
  <el-drawer
    :visible="drawer"
    :show-close="false"
    @close="handleClose"
    size="35.5%"
    class="detailDrawer"
  >
    <div class="drawerWrapper">
      <div v-if="activeKey == '1'" class="wrap">
        <el-tabs v-model="activeName" ref="tabs" @tab-click="handleClick">
          <el-tab-pane label="基本信息" name="1"></el-tab-pane>
          <el-tab-pane label="支付信息" name="2"></el-tab-pane>
          <el-tab-pane label="退款信息" name="3"></el-tab-pane>
          <el-tab-pane label="分润信息" name="4"></el-tab-pane>
        </el-tabs>
        <div v-if="activeName == '1'" class="tabContnet">
          <ul class="list">
            <li class="item">
              <div class="tit">创建时间</div>
              <div class="desc">
                {{ info.gmtCreated ? info.gmtCreated : "-" }}
              </div>
            </li>
            <!-- <li class="item">
              <div class="tit">所属商户</div>
              <div class="desc">
                {{ info.memberName ? info.memberName : "-" }}
              </div>
            </li> -->
            <li class="item">
              <div class="tit">商户订单号</div>
              <div class="desc">
                {{ info.merchantOrderNo ? info.merchantOrderNo : "-" }}
              </div>
              <div
                v-if="info.merchantOrderNo"
                style="margin-left: 32px; color: #03bfc6; cursor: pointer"
              >
                <i
                  class="el-icon-document-copy"
                  @click="copyAppId(info.merchantOrderNo)"
                ></i>
              </div>
            </li>
            <li class="item">
              <div class="tit">云尘付流水号</div>
              <div class="desc">
                {{ info.innerOrderNo ? info.innerOrderNo : "-" }}
              </div>
              <div
                v-if="info.innerOrderNo"
                style="margin-left: 32px; color: #03bfc6; cursor: pointer"
              >
                <i
                  class="el-icon-document-copy"
                  @click="copyAppId(info.innerOrderNo)"
                ></i>
              </div>
            </li>
            <li class="item">
              <div class="tit">商品名称</div>
              <div class="desc">
                {{ info.subject ? info.subject : "-" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">商品描述</div>
              <div class="desc">
                {{ info.body ? info.body : "-" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">备注</div>
              <div class="desc">
                {{ info.description ? info.description : "-" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">付款方</div>
              <div class="desc">
                {{ info.userName ? info.userName : "-" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">订单金额/元</div>
              <div class="desc">
                {{ info.fmtOriginalAmount ? info.fmtOriginalAmount : "-" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">优惠金额/元</div>
              <div class="desc">
                {{ info.fmtDiscountAmount ? info.fmtDiscountAmount : "-" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">应付金额/元</div>
              <div class="desc">
                {{ info.fmtActualAmount ? info.fmtActualAmount : "-" }}
              </div>
            </li>
          </ul>
        </div>
        <div v-if="activeName == '2'" class="tabContnet">
          <ul class="list" v-for="item,index in info.businessOrderPayResponse.chargeResponseList" :key="index" style="margin-bottom:40px ;">
            <li class="item">
              <div class="tit">云尘付流水号</div>
              <div class="desc">
          {{item.merchantChargeNo}}
              </div>
            </li>
              <li class="item">
              <div class="tit">支付状态</div>
              <div class="desc">
                {{item.statusName}}
              </div>
            </li>
            <li class="item">
              <div class="tit">支付渠道</div>
              <div class="desc">
              {{item.channelName}}
              </div>
            </li>
            <li class="item">
              <div class="tit">支付金额</div>
              <div class="desc">
                ￥  {{item.fmtActualAmount}}
              </div>
            </li>
          </ul>
        </div>
        <div v-if="activeName == '3'" class="tabContnet">
          <ul class="list">
            <li class="item">
              <div class="tit">退款情况</div>
              <div class="desc">
                {{ info.businessOrderRefundResponse.refund ? "有" : "无" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">退款总金额</div>
              <div class="desc">
                {{
                  info.businessOrderRefundResponse.fmtTotalRefundAmount
                    ? info.businessOrderRefundResponse.fmtTotalRefundAmount
                    : "-"
                }}
              </div>
            </li>
            <li class="item-table">
              <el-table :data="info.businessOrderRefundResponse.refundList">
                <template slot="empty">
                  <el-empty
                    :image="require('@/assets/imgs/middleWork/k1.png')"
                    :image-size="80"
                    description="暂无相关数据"
                  ></el-empty>
                </template>
                <!-- <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="退款订单号"
                  prop="refundNo"
                  :width="
                    this.$flexColumnWidth(
                      'refundNo',
                      info.businessRefundRes.businessRefundListResList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.refundNo ? scope.row.refundNo : "-" }}
                    </div>
                  </template>
                </el-table-column> -->
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="退款流水号"
                  prop="innerRefundNo"
                  :width="
                    this.$flexColumnWidth(
                      'innerRefundNo',
                      info.businessOrderRefundResponse.refundList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{
                        scope.row.innerRefundNo ? scope.row.innerRefundNo : "-"
                      }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="退款金额/元"
                  prop="refundAmount"
                  :width="
                    this.$flexColumnWidth(
                      'refundAmount',
                      info.businessOrderRefundResponse.refundList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{
                        scope.row.refundAmount ? scope.row.refundAmount : "-"
                      }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="返还手续费/元"
                  prop="refundFee"
                  :width="
                    this.$flexColumnWidth(
                      'refundFee',
                      info.businessOrderRefundResponse.refundList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.refundFee ? scope.row.refundFee : "-" }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="退款状态"
                  prop="refundStatus"
                  :width="
                    this.$flexColumnWidth(
                      'refundStatusName',
                      info.businessOrderRefundResponse.refundList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{
                        scope.row.refundStatusName
                          ? scope.row.refundStatusName
                          : "-"
                      }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="退款时间"
                  prop="refundTime"
                  :width="
                    this.$flexColumnWidth(
                      'refundTime',
                      info.businessOrderRefundResponse.refundList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.refundTime ? scope.row.refundTime : "-" }}
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </li>
          </ul>
        </div>
        <div v-if="activeName == '4'" class="tabContnet">
          <ul class="list">
            <li class="item">
              <div class="tit">分润情况</div>
              <div class="desc">
                {{ info.royaltyResponse.royalty ? "有" : "无" }}
              </div>
            </li>
            <li class="item">
              <div class="tit">分润总金额/元</div>
              <div class="desc">
                {{
                  info.royaltyResponse.fmtTotalRoyaltyAmount
                    ? "￥" + info.royaltyResponse.fmtTotalRoyaltyAmount
                    : "-"
                }}
              </div>
            </li>
            <li class="item-table">
              <el-table :data="info.royaltyResponse.royaltyResponseList">
                <template slot="empty">
                  <el-empty
                    :image="require('@/assets/imgs/middleWork/k1.png')"
                    :image-size="80"
                    description="暂无相关数据"
                  ></el-empty>
                </template>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="分润方名称"
                  prop="userName"
                  :width="
                    this.$flexColumnWidth(
                      'userName',
                      info.royaltyResponse.royaltyResponseList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.userName ? scope.row.userName : "-" }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="分润金额/元"
                  prop="fmtAmount"
                  :width="
                    this.$flexColumnWidth(
                      'fmtAmount',
                      info.royaltyResponse.royaltyResponseList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{
                        scope.row.fmtAmount
                          ? scope.row.fmtAmount
                          : "-"
                      }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="分润类型"
                  prop="royaltyTypeName"
                  :width="
                    this.$flexColumnWidth(
                      'royaltyTypeName',
                      info.royaltyResponse.royaltyResponseList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{
                        scope.row.royaltyTypeName
                          ? scope.row.royaltyTypeName
                          : "-"
                      }}
                    </div>
                  </template>
                </el-table-column>
                <!-- <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="结算渠道"
                  prop="refundTime"
                  :width="
                    this.$flexColumnWidth(
                      'channelName',
                      info.royaltyResponse.royaltyResponseList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.refundTime ? scope.row.refundTime : "-" }}
                    </div>
                  </template>
                </el-table-column> -->
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="结算状态"
                  prop="statusName"
                  :width="
                    this.$flexColumnWidth(
                      'statusName',
                      info.royaltyResponse.royaltyResponseList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.statusName ? scope.row.statusName : "-" }}
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </li>
            <!-- <li class="item">
              <div class="tit">分润发起方</div>
              <div class="desc">
                {{
                  info.businessSettleRes.memberName
                    ? info.businessSettleRes.memberName
                    : "-"
                }}
              </div>
            </li>
            <li class="item">
              <div class="tit">分润状态</div>
              <div class="desc">
                {{
                  info.businessSettleRes.settleStatus
                    ? info.businessSettleRes.settleStatus
                    : "-"
                }}
              </div>
            </li>
            <li class="item-table">
              <el-table
                :data="info.businessSettleRes.businessSettleListResList"
              >
                <template slot="empty">
                  <el-empty
                    :image="require('@/assets/imgs/middleWork/k1.png')"
                    :image-size="80"
                    description="暂无相关数据"
                  ></el-empty>
                </template>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="分润接收方"
                  prop="memberName"
                  :width="
                    this.$flexColumnWidth(
                      'memberName',
                      info.businessSettleRes.businessSettleListResList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.memberName ? scope.row.memberName : "-" }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="分润方接收方ID"
                  prop="memberNo"
                  :width="
                    this.$flexColumnWidth(
                      'memberNo',
                      info.businessSettleRes.businessSettleListResList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.memberNo ? scope.row.memberNo : "-" }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="分润金额/元"
                  prop="fmtSettleAmount"
                  :width="
                    this.$flexColumnWidth(
                      'fmtSettleAmount',
                      info.businessSettleRes.businessSettleListResList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{
                        scope.row.fmtSettleAmount
                          ? scope.row.fmtSettleAmount
                          : "-"
                      }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="结算类型"
                  prop="fmtSettleAmount"
                  :width="
                    this.$flexColumnWidth(
                      'fmtSettleAmount',
                      info.businessSettleRes.businessSettleListResList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.settleType ? scope.row.settleType : "-" }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="结算状态"
                  prop="settleFinish"
                  :width="
                    this.$flexColumnWidth(
                      'settleFinish',
                      info.businessSettleRes.businessSettleListResList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{
                        scope.row.settleFinish == 0
                          ? "未结算"
                          : scope.row.settleFinish == 1
                          ? "结算成功"
                          : scope.row.settleFinish == 2
                          ? "处理中"
                          : "结算失败"
                      }}
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  show-overflow-tooltip
                  align="center"
                  label="分润完成时间"
                  prop="finishTime"
                  :width="
                    this.$flexColumnWidth(
                      'finishTime',
                      info.businessSettleRes.businessSettleListResList
                    )
                  "
                >
                  <template slot-scope="scope">
                    <div
                      style="
                        overflow: hidden;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                      "
                    >
                      {{ scope.row.finishTime ? scope.row.finishTime : "-" }}
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </li> -->
          </ul>
        </div>
      </div>
    </div>
  </el-drawer>
</template>

<script>
export default {
  props: {
    drawer: {
      type: Boolean,
    },
    info: {
      type: Object,
      default: () => ({}),
    },
    activeKey: {
      type: String,
      default: "1",
    },
    width: {
      type: String,
      default: "140px",
    },
  },
  components: {},
  data() {
    return {
      resetKey: false,
      activeName: "1",
    };
  },
  methods: {
    handleClose() {
      this.$emit("update:drawer", false);
      this.activeName = "1";
    },
    handleClick() {
      this.resetActivePosition(this.$refs.tabs.$el);
    },
    resetActivePosition($el) {
      this.$nextTick(() => {
        const activeEl = $el.querySelector(".el-tabs__item.is-active");
        const lineEl = $el.querySelector(".el-tabs__active-bar");
        const style = getComputedStyle(activeEl);
        const pl = style.paddingLeft.match(/\d+/)[0] * 1;
        const pr = style.paddingRight.match(/\d+/)[0] * 1;
        const w = style.width.match(/\d+/)[0] * 1;
        lineEl.style.transform =
          "translateX(" + (activeEl.offsetLeft + pl) + "px)";
        lineEl.style.width = w - pl - pr + "px";
      });
    },
    copyAppId(value) {
      const input = document.createElement("input"); // 创建input对象
      input.value = value; // 设置复制内容
      document.body.appendChild(input); // 添加临时实例
      input.select(); // 选择实例内容
      document.execCommand("Copy"); // 执行复制
      document.body.removeChild(input); // 删除临时实例
      this.$message.success("复制成功！");
    },
  },
};
</script>

<style lang="scss" scoped>
.drawerWrapper {
  padding: 0 50px;
}

.tabContnet {
  margin-top: 30px;
  .item {
    display: flex;
    align-items: flex-start;
    min-height: 20px;
    // line-height: 40px;
    margin-bottom: 20px;
    div {
      // display: inline-block;
      &.tit {
        min-width: 88px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #869daa;
        margin-right: 26px;
      }
      &.desc {
        display: flex;
        // justify-content: space-around;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #1d1c1c;
        span {
          display: inline-block;
          margin-right: 10px;
          &.hidText {
            display: inline-block;
            width: 230px;
            overflow: hidden; //溢出隐藏
            white-space: nowrap; //禁止换行
            text-overflow: ellipsis; //...
          }
          &.highCol {
            color: #03bfc6;
          }
        }
      }
    }
  }
  .item-table {
    margin-top: 17px;
    :deep(.el-table .el-table__header-wrapper .el-table__cell) {
      height: 34px;
    }
    :deep(.el-table .el-table__body-wrapper .el-table__cell) {
      height: 34px;
    }
  }
}

:deep(.el-tabs__item) {
  width: 72px !important;
  font-size: 18px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  margin-right: 40px;
}
:deep(.el-tabs__active-bar) {
  top: unset;
  bottom: 0;
  height: 1px;
}
</style>
